package system.controller;

import common.controller.base.BaseController;
import common.model.request.ModifyPasswordRequest;
import common.model.request.ValidateTokenRequest;
import common.model.response.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import system.service.ModifyPasswordService;

import javax.annotation.Resource;

/**
 * 修改密码
 *
 * @author 米泽鹏
 * @since 2023-11-06
 */
@Api(tags = "修改密码")
@RestController
@RequestMapping("/system/modify-password")
public class ModifyPasswordController extends BaseController {

	@Resource
	private ModifyPasswordService modifyPasswordService;

	@ApiOperation(value = "校验token", notes = "校验token")
	@PostMapping("/validateToken")
	public Result<?> validateToken(@ApiParam(value = "校验token请求", required = true) @RequestBody @Validated ValidateTokenRequest request) {
		return successWithData(modifyPasswordService.validateToken(request.getToken()));
	}

	@ApiOperation(value = "修改密码", notes = "修改密码")
	@PostMapping("/modifyPassword")
	public Result<?> modifyPassword(@ApiParam(value = "修改密码请求", required = true) @RequestBody @Validated ModifyPasswordRequest request) {
		return modifyPasswordService.modifyPassword(request);
	}

}
